#ifndef _RAM_H_
#define _RAM_H_

#include "core/Core.h"
#include "device/Device.h"

#include <cstring>
#include <fstream>
#include <filesystem>

#define MEM_BASE 0x80000000ul
#define MEM_SIZE 0x10000000ul

class Memory : public Device {
public:
    Memory(size_t mem_size = MEM_SIZE);
    Memory(uint8_t* bin, size_t bin_size, size_t mem_size = MEM_SIZE);
    Memory(const char* filename, size_t mem_size = MEM_SIZE);
    ~Memory();
    bool read(word_t start_addr, size_t length, uint8_t* buffer) override;
    bool write(word_t start_addr, size_t length, const uint8_t* buffer) override;
    void update() override;
    word_t get_size();
    uint8_t* get_base();
private:
    uint8_t* data;
    size_t size;
};
#endif